package controller

import (
	"git.mycaigou.com/gfyx/micro-gfyx-bigdata-service/infrastructure/dto"
	contract2 "git.mycaigou.com/gfyx/micro-gfyx-bigdata-service/service/bigdata/contract"
	"github.com/gin-gonic/gin"
)

type WriteController struct {
	BaseController
	writeService contract2.WriteServiceIface
}

func NewWriteController(writeService contract2.WriteServiceIface) *WriteController {
	return &WriteController{
		writeService: writeService,
	}
}

func (w *WriteController) RegisterRouter(g *gin.RouterGroup) {
	g.POST("/save-rcc-contact-info", w.SaveRCCContactInfo)
}

// 保持RCC的联系人信息
func (w *WriteController) SaveRCCContactInfo(ctx *gin.Context) {
	contactInfoList := make([]*dto.RCCContactInfo, 0)
	if err := ctx.ShouldBindJSON(&contactInfoList); err != nil {
		w.Fail(ctx, -1, err.Error())
		return
	}

	if err := w.writeService.SaveRCCContactInfo(ctx, contactInfoList); err != nil {
		w.Fail(ctx, -1, err.Error())
		return
	}

	w.Success(ctx, map[string]interface{}{})
}
